/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package file.reader;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Romms
 */
public class FileReader {

    private File file;
    private ArrayList<String> fileLines;
    

    /**
    * @param aFileName full name of an existing, readable file.
    */
    public FileReader(String aFileName){
        fileLines = new ArrayList<String>();
        file = new File(aFileName);
    }

    public ArrayList<String> getFileContent() throws FileNotFoundException{
        return retrieveFileContent();
    }

    private ArrayList<String>  retrieveFileContent() throws FileNotFoundException {
        Scanner fileScanner = new Scanner(file);
        try {
            while ( fileScanner.hasNextLine() ){
                fileLines.add( fileScanner.nextLine() );
            }
            return fileLines;
        }
        finally {
            fileScanner.close();
        }
    }
}
